# $Id$
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=libwmf
pkgver=0.2.8.4
pkgrel=14
pkgdesc="A library for reading vector images in Microsoft's native Windows Metafile Format (WMF)"
arch=('i686' 'x86_64')
url="http://wvware.sourceforge.net/libwmf.html"
license=('LGPL')
depends=('libx11' 'libjpeg' 'gsfonts')
makedepends=('gtk2' 'libxt')
optdepends=('gdk-pixbuf2: for pixbuf loader')
options=('!docs' '!emptydirs')
source=(http://downloads.sourceforge.net/sourceforge/wvware/${pkgname}-${pkgver}.tar.gz
        libwmf-0.2.8.4-libpng-1.5.patch
        libwmf-0.2.8.4-useafterfree-CVE-2009-1364.patch
        libwmf-0.2.8.4-intoverflow-CVE-2006-3376.patch
        libwmf-0.2.8.4-CAN-2004-0941.patch
        libwmf-0.2.8.4-CVE-2007-0455.patch
        libwmf-0.2.8.4-CVE-2007-2756.patch
        libwmf-0.2.8.4-CVE-2007-3472.patch
        libwmf-0.2.8.4-CVE-2007-3473.patch
        libwmf-0.2.8.4-CVE-2007-3477.patch
        libwmf-0.2.8.4-CVE-2009-3546.patch
        libwmf-0.2.8.4-CVE-2015-0848+CVE-2015-4588.patch
        libwmf-0.2.8.4-CVE-2015-4695.patch
        libwmf-0.2.8.4-CVE-2015-4696.patch
		libwmf-0.2.8.4-CVE-2016-9011.patch)
sha1sums=('822ab3bd0f5e8f39ad732f2774a8e9f18fc91e89'
          '42aa4c2a82e4e14044c875a7f439baea732a355a'
          'ea6d28880840e86c96f9079bfd591da54dcffa5c'
          '6f130ea9f639ccf88fef0fda74cf9fa3956f81b5'
          '2f8a46698dac6d5f5c3109cb56ad675ff1efaee0'
          '380d59744f174e12d4ba4f5cb63f14b6092850fa'
          '45ae37f79b351fe738212caa3a3c61c9b6fa2d5b'
          '1836f07750d3a8b4dd6354660875436b0e5c3b07'
          'c778b89445f621fd5e44b0bbf9d441cceea90d6c'
          'd0a6fefedd327f99c3ca1c2f7f19adddc2cef50a'
          '83f32dac05c1492eef1e652c553a5ffc80a3e656'
          '5608d0565890f2f89435bc13ad57279900ed83b4'
          '408cfff29160b037b8baa26b4647e02f373b8b85'
          'e250f5ecefde4bf5c06f7fbc562566ce64204f2a'
          '9f8670ef0b4862bb84aecc582bfbec45573a8831')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-libpng-1.5.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-useafterfree-CVE-2009-1364.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-intoverflow-CVE-2006-3376.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CAN-2004-0941.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2007-0455.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2007-2756.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2007-3472.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2007-3473.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2007-3477.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2009-3546.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2015-0848+CVE-2015-4588.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2015-4695.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2015-4696.patch"
  patch -p1 -i "${srcdir}/libwmf-0.2.8.4-CVE-2016-9011.patch"
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr \
              --with-gsfontdir=/usr/share/fonts/Type1 \
	      --with-fontdir=/usr/share/fonts/Type1 \
	      --with-gsfontmap=/usr/share/ghostscript/9.10/Resource/Init/Fontmap.GS
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  #Remove fonts, these are in gsfonts
  rm -rf "${pkgdir}/usr/share/fonts"
}
